package week1;

public class Administrators {
    String name;
    int key;
}
import java.util.Scanner;

//更改管理员密码那题：模拟实现用户密码管理：管理员有用户和密码两个属性，
// 输入旧的用户名和密码，如果正确，方有权限更新；从键盘获取新的密码，进行更新
public class Oppzy01 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Administrators ad = new Administrators();
        ad.name = "zhou";
        ad.key = 666666;
        while (true) {
            System.out.println("Please input your name:");
            String name = in.next();
            System.out.println("Please input your key:");
            int key = in.nextInt();
            if (name.equals(ad.name) && key == ad.key) {
                System.out.println("Please input new key:");
                ad.key = in.nextInt();
                System.out.println("Your new key is " + ad.key);
                break;
            } else {
                System.out.println("Error!You can not change information!");
                System.out.println("Please input again.");
            }
        }
    }
}